package edu.hawaii.ics414.blackjack.player;

import edu.hawaii.ics414.blackjack.card.GameDeck;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import org.junit.Test;

/**
 * Tests the Dealer class.
 * 
 * @author Branden Ogata
 *
 */

public class TestDealer
{
  /**
   * Tests the methods in the Dealer class.
   * 
   */
  
  @Test
  public void test()
  {
    Dealer dealer = new Dealer(1);
    GameDeck deck = new GameDeck(6);
    
    // Test getCards
    dealer.startHand(deck);
    assertTrue("Should initially show hole card only", 
               (dealer.getCards()).endsWith(dealer.getHoleCard() + " XX \n"));
    
    // Should hit if 16 or less
    TestPlayer.makeHandOfValue(dealer, deck, 16);
    assertEquals("Should hit with 16", Action.HIT, dealer.getMove(deck, 0, null));
    
    // Should hit with soft 17
    TestPlayer.makeSoftHand(dealer, deck, 17);
    assertEquals("Should hit with soft 17", Action.HIT, dealer.getMove(deck, 0, null));
    
    // Should stand with hard 17
    TestPlayer.makeHardHand(dealer, deck, 17);
    assertEquals("Should stand with hard 17", Action.STAND, dealer.getMove(deck, 0, null));
    
    // Should stand if more than 17
    TestPlayer.makeHandOfValue(dealer, deck, 18);
    assertEquals("Should stand with 18", Action.STAND, dealer.getMove(deck, 0, null));
  }

}
